<template>
	<view >
		<view>
			<u-navbar
				:autoBack="false"
				:placeholder="true"
				bgColor="rgba(255, 255, 255, 1)"
				@leftClick="leftClick"
			/>
		</view>
		<view style="margin-left: 52.3rpx;margin-right: 52.3rpx; margin-bottom: 10rpx;">
			<u--text lineHeight="33" size="16px" :text="content[lest]"></u--text>
			<view style="margin-top: 10px;margin-bottom: 10px;" v-if="image.length>=lest+1">
				<u--image :src="oss_host+image[lest]" width="100%" @click="click_swiper(image[lest])"></u--image>
			</view>
		</view>
		<view style="width: 100%; height: 80rpx;"></view>
		<view class="fan">{{lest+1}}/{{length}}</view>
		<u-tabbar
			:fixed="true"
			:placeholder="true"
			:safeAreaInsetBottom="true"
			:border="false"
		>
		<view v-if="length==1">
			<button class="button1">首页</button>
			<button class="button1">尾页</button>
		</view>
		 <!-- style="position: absolute; bottom: 0;margin-bottom: 20px;z-index: 1;" -->
		<view  v-if="length>=2">
			
			<view v-if="lest==0">
				<button class="button1">首页</button>
				<button  class="button1" @click="lest+=1">下一页</button>
			</view>
			<view v-else-if="lest+1==length">
				<button  class="button1" @click="lest-=1">上一页</button>
				<button class="button1">尾页</button>
			</view>
			<view v-else>
				<button  class="button1" @click="lest-=1">上一页</button>
				<button  class="button1" @click="lest+=1">下一页</button>
			</view>
		</view>
		</u-tabbar>
	</view>
	
</template>

<script>
	import {
		oss_host
	} from '../../utils/appInfo'
	export default {
		data() {
			return {
				oss_host: oss_host,
				content: [],
				image: [],
				datas: {},
				length: 0,
				_id: -1,
				lest: 0
			}
		},
		onLoad(res) {
			this._id = res.id
			this.api.getProfileInfo({
				id: this._id
			}).then(res => {
				console.log(res.data)
				this.image = res.data.image
				this.length = res.data.content.length
				for (let i = 0; i < res.data.content.length; i++) {
					this.content[i] = res.data.content[i].replace(/<[^>]*>/g, '')
				}
			})
			this.api.getIndex({
				id: this._id
			}).then(res => {
				this.datas = res.data
				uni.setNavigationBarTitle({
					title: this.datas.name + "的简介"
				})
			})
		},
		methods:{
			leftClick() {
				if(this.lest>0){
					this.lest=0
				}else{
					uni.navigateTo({
						url:"index?id="+this._id
					})
				}
			},
			click_swiper(url){
				let urls=[]
					urls.push(this.oss_host+url)
				uni.previewImage({
						urls:urls,
				})
			}
		}
	}
</script>

<style>
	.fan {
		background-color: #ffffff;
		text-align: center;
		position: fixed;
		width: 100%;
		bottom: 0; /* 吸底设置 */
		height: 180rpx; /* 底部吸底区域的高度 */
	}

	.tab {
		margin-top: 19rpx;
		border-collapse: collapse;
		width: 97%;
		height: 427rpx;
	}

	.button {
		border-radius: 20px;
		background: rgba(229, 229, 229, 1);
		color: rgba(255, 141, 26, 1);
		width: 375rpx;
		float: left;
	}

	.button1 {
		border-radius: 20px;
		background: rgba(255, 141, 26, 1);
		color: rgba(229, 229, 229, 1);
		width: 375rpx;
		float: left;
	}
</style>